<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.css" rel="stylesheet">
</head>
<script>
  onload = function(){
    var usrname = document.getElementById("username");
    usrname.onkeydown = function(event){
      var e = evt||event;
      console.log(event.keyCode);
    }
  }
</script>
<body>

  <div class="input-group col-4">
    <span class="input-group-addon" id="basic-addon1">@</span>
    <input type="text" class="form-control" placeholder="Username" id="username" aria-describedby="basic-addon1">
  </div>
  
</body>
</html>